package com.liuxinlong.modules.chimi.controller;

import com.liuxinlong.modules.chimi.controller.request.QueryCardManageReq;
import com.liuxinlong.modules.chimi.service.BarManageService;
import com.liuxinlong.modules.common.controller.response.BaseResp;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 论坛统计控制层
 *
 * @author liuxinlong@hotwater.com.cn
 * @version 1.0.0
 * @since 2023-05-16
 */
@RestController
@RequestMapping({"/bar/analysis"})
public class BarAnalysisController {
    @Autowired
    private BarManageService barManageService;

    /**
     * 论坛统计首页
     *
     * @return 论坛统计首页信息
     */
    @PostMapping({"page"})
    public BaseResp pageCardInfo(@RequestBody QueryCardManageReq req) {
        Map<String, Object> queryParam = new HashMap<>();
        queryParam.put("startNum", Integer.valueOf(req.getStartNum()));
        queryParam.put("pageSize", Integer.valueOf(req.getPageSize()));
        queryParam.put("status", Integer.valueOf(req.getStatus()));
        queryParam.put("title", req.getTitle());
        queryParam.put("plate", req.getPlate());
        queryParam.put("createUser", req.getCreateUser());
        List<Map<String, Object>> dataList = this.barManageService.pageCard(queryParam);
        int total = this.barManageService.getCardCount(queryParam);
        BaseResp resp = new BaseResp();
        resp.setDataList(dataList);
        resp.setTotalNum(total);
        resp.setRetMessage("");
        return resp;
    }

}
